﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MezmurStore2.Models;

namespace MezmurStore2.Controllers
{
    public class PlayerController : BaseController
    {
        private MezmurStoreEntities db = new MezmurStoreEntities();

        //
        // GET: /MadiaPlayer/

        public ViewResult Index()
        {
            List<string> artists = new List<string>();
            foreach(var artist in db.Tracks)
            {
                if (artists.Contains(artist.ArtistName) == false)
                {
                    artists.Add(artist.ArtistName);
                }
            }
            ViewBag.Artists = artists;
            ViewBag.Albums = db.Albums.ToList();

            List<string> categories = new List<string>();
            foreach(var category in db.Categories)
            {
                var c = category.ToString();
                if (db.Albums.Any(a =>a.Gener == c))
                {
                    categories.Add(category.ToString());
                }
            }
            ViewBag.Categories = categories;

            return View();
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}